﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CreatePGSQLDataScript
{
    public partial class DiagramList : Form
    {
        public DiagramList()
        {
            InitializeComponent();
        }

        private void DiagramList_Load(object sender, EventArgs e)
        {
            DataAccess.SqlProvider db;
            db = new DataAccess.SqlProvider(OisLibrary.DB.Connection);

            string sqlText = @"select distinct diagram from ProgramTimeOrder";
            DataTable dt = db.GetDataTable(sqlText);
            listBox1.DisplayMember = "diagram";
            listBox1.ValueMember = "diagram";
            listBox1.DataSource = dt;

        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            string value = listBox1.SelectedValue.ToString();

            ProgramTimeFlow pp = new ProgramTimeFlow(value);
            this.Hide();
            pp.ShowDialog();
            this.Show(); 
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            string value = txtDiagramName.Text.Trim();

            ProgramTimeFlow pp = new ProgramTimeFlow(value);
            this.Hide();
            pp.ShowDialog();
            this.Show();
        }
    }
}
